﻿using Dapper;
using System.Collections.Generic;
using zhangmenren.Db;
using zhangmenren.Models;

namespace zhangmenren.Repository
{
	public class QiYeRepository : BaseRepository
	{
		public int Add(QiYeShouChangEntity entity)
		{
			string sql = @"INSERT INTO QiYeShouChang 
                            (QiYeId
                            ,UserId
                            ,AddDT)
                        VALUES
                            (@QiYeId
                            ,@UserId
                            ,GETDATE())";
			return Execute(connection => connection.Execute(sql, entity));
		}

		public IEnumerable<QiYeShouChangEntity> Select(QiYeShouChangEntity entity)
		{
			string sql = @"SELECT Id FROM QiYeShouChang WHERE UserId = @UserId AND QiYeId=QiYeId";
			return Execute(connection => connection.Query<QiYeShouChangEntity>(sql, entity));
		}

		public int Del(QiYeShouChangEntity entity)
		{
			string sql = @"DELETE FROM QiYeShouChang WHERE UserId = @UserId AND QiYeId=QiYeId";
			return Execute(connection => connection.Execute(sql, entity));
		}

	}
}
